__author__="root"
__date__ ="$Sep 30, 2009 7:44:11 PM$"

from Class import Class
import sql

ClassList = []

def GetClass( teacher, period, classname ):

    for ClassObj in ClassList:
        if ClassObj.Teacher == teacher and ClassObj.Period == period and ClassObj.ClassName == classname:
            return ClassObj

    NewClass = Class( teacher, period, classname )
    NewClass.InsertIntoDatabase()

    ClassList.append( NewClass )


def LoadClasses():
    cursor = sql.conn.cursor ()

    cursor.execute ("SELECT `id`,`teacher`,`period`,`class` FROM `ps_classes`")

    rows = cursor.fetchall ()
    for row in rows:
        NewClass = Class( row[1], row[2], row[3] )
        NewClass.SetId( row[0] )
        ClassList.append( NewClass )

    



